package com.xin.data.simbapesa.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bumptech.glide.Glide;
import com.xin.data.simbapesa.R;
import com.xin.data.simbapesa.api.U;
import com.xin.data.simbapesa.base.BaseBindingAdapter1;
import com.xin.data.simbapesa.databinding.SimbaCardItemBinding;
import com.xin.data.simbapesa.obj.SimbaAccountItem;
import com.xin.data.simbapesa.utils.LogUtil;
import com.xin.data.simbapesa.utils.ViewUtils;

import java.util.List;

public class CardAdapter extends BaseBindingAdapter1<SimbaAccountItem, SimbaCardItemBinding> {


    public CardAdapter(List<SimbaAccountItem> dataList) {
        super(dataList);
    }

    @Override
    protected void bindData(SimbaCardItemBinding binding, SimbaAccountItem item, int position) {

        Glide.with(binding.tvIcon.getContext()).load(item.getWalletLogo()).placeholder(R.mipmap.logo).into(binding.tvIcon);
        LogUtil.e("me", "item.getWalletDesc()->" + item.getWalletDesc()+",position->"+position);
        binding.tvTitle.setText(item.getWalletDesc());
        binding.tvTitle1.setVisibility(View.VISIBLE);
        binding.tvTitle1.setText(item.getWalletMobile());


        binding.tvAdd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ViewUtils.viewScale(v);
                if (onBtnItemClickListener != null) {
                    onBtnItemClickListener.onItemClick(position);
                }
            }
        });

        if (U.isCameroon) {
            binding.tvAdd.setVisibility(View.VISIBLE);
        } else {
            binding.tvAdd.setVisibility(View.GONE);
        }

    }

    @Override
    protected int getItemType(SimbaAccountItem item) {
        return 0;
    }

    @Override
    protected SimbaCardItemBinding createBinding(LayoutInflater inflater, ViewGroup parent, int viewType) {
        return SimbaCardItemBinding.inflate(inflater, parent, false);
    }


}
